﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strUserName = this.txtLoginName.Text;
        string strPwd = this.txtPwd.Text;
        string strCode = this.txtCheckCode.Text.ToUpper();

        if (Response.Cookies["CheckCode"] == null)
        {
            this.lblAlert.Text = "验证码输入有误";
            return;
        }
        string strCookie = Request.Cookies.Get("CheckCode").Value;

        if (strUserName == "" || strPwd == "" || strCode == "")
        {
            OTS.Common.Jscript.Alert("参数有误！");
            return;
        }
        if (strCode != strCookie)
        {
            this.lblAlert.Text = "验证码输入有误";
            return;
        }
        OTS.BLL.CustomBLL bll = new OTS.BLL.CustomBLL();
        OTS.Model.custom model = bll.Login(strUserName, strPwd);
        if (model == null)
        {
            this.lblAlert.Text = "登陆失败！请检查输入的用户名和密码！";
            return;
        }
        Session["custom"] = model;
        string strRed = Request.QueryString["redirectUrl"];
        if (strRed == null || "".Equals(strRed))
        {
            Response.Redirect("Index.aspx");
        }
        else
        {
            Response.Redirect(Request.QueryString["redirectUrl"].ToString());
        }
        
    }
}
